set more 1

/*
File:	cepr_basic_demog.do
Date:	Nov 21, 2006
	Feb 16, 2008
	Feb 10, 2009
	Oct 27, 2009
	Jan 4, 2010
	Feb 22, 2011
	Jan 3, 2012
	Jan 3, 2013
	Dec 20, 2013
	Mar 12, 2015, CEPR ORG Version 2.0
	Apr  1, 2015, CEPR ORG Version 2.0.1
	March 1, 2016, CEPR ORG Version 2.1
	Oct 12, 2016, CEPR ORG Version 2.1.1
	Feb 9, 2017, CEPR ORG Version 2.2
	Apr 21, 2017, CEPR ORG Version 2.2.1
	Apr 10, 2018, CEPR ORG Version 2.3
	Mar 22, 2019, CEPR ORG Version 2.4
	Jul 24, 2019, CEPR ORG Version 2.4.1
	Feb 05, 2020, CEPR ORG Version 2.5
	
Desc:	Creates consistent demographic variables for CEPR consistent extract
	of Basic CPS
Note:	See copyright notice at end of program.
*/

/* note: any pre-1994 data processing is not yet correct;
         use only to process data from 1994 forward
*/

/* Determine data year */

local year=year in 1

/* Age */

gen int age=.

if `year'==1991 {
replace age=adage
replace age=. if adage<0 | 90<adage
}
if 1994<=`year' & `year'<=2020 {
capture rename prtage peage
replace age=peage
replace age=. if peage<0
}

lab var age "Age"
notes age: CPS: a-age, peage

/* Gender */

gen byte female=.

if `year'==1991 {
replace female=0 if adsex==1
replace female=1 if adsex==2
}
if 1994<=`year' & `year'<=2020 {
replace female=0 if pesex==1
replace female=1 if pesex==2
}
lab var female "Female"
notes female: CPS: pesex, adsex

/* Race and ethnicity */

	/*
	   NOTE: major recode of CPS race variable in 2003
	*/

	/* wbho */
	
gen byte wbho=.

if `year'<=1991 {
replace wbho=1 if adrace==1 /* white */
replace wbho=2 if adrace==2 /* black */
replace wbho=4 if (3<=adrace & adrace<=5)
/* american indian, aleut eskimo; asian or pacific island; other */
replace wbho=3 if (1<=adreorgn & adreorgn<=7) /* hispanic origin */
}
if 1994<=`year' & `year'<=2002 {
replace wbho=1 if perace==1
replace wbho=2 if perace==2
replace wbho=4 if (3<=perace & perace<=5)
replace wbho=3 if (1<=prorigin & prorigin<=7) 
}

/* new code */
if 2005 == `year' {
replace prdtrace = ptdtrace if (8<=month & month<=12)
}
if `year'==2006 {
rename ptdtrace prdtrace
}
if 2009<=`year' & `year'<=2020 {
rename ptdtrace prdtrace
}
if 2003<=`year' & `year'<=2011 {
replace wbho=1 if prdtrace==1
replace wbho=2 if prdtrace==2
replace wbho=2 if prdtrace==6 /* black-white */ | prdtrace==10 /*
*/ /* black-AI */ | prdtrace==11 /* black-asian */ | prdtrace==12 /*
*/ /* black-HP */ | prdtrace==15 /* W-B-AI */ | prdtrace==16 /* W-B-A */ /*
*/ | prdtrace==19 /* W-B-AI-A */
replace wbho=4 if (3<=prdtrace & prdtrace<=5)
replace wbho=4 if prdtrace==7 /* white-AI */ | prdtrace==8 /*
*/ /* white-asian */ | prdtrace==9 /* white-hawaiian */ | prdtrace==13 /*
*/ /* AI-asian */ | prdtrace==14 /* Asian-HP */ | prdtrace==17 /* W-AI-A */ /*
*/ | prdtrace==18 /* W-A-HP */ | prdtrace==20 /* 2 or 3 races */ /*
*/ | prdtrace==21 /* 4 or 5 races */
replace wbho=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2012==`year' {
  replace wbho=1 if (1<=month & month<=4) & prdtrace==1
  replace wbho=2 if (1<=month & month<=4) & prdtrace==2
  replace wbho=2 if (1<=month & month<=4) & (prdtrace==6 /* black-white */ /*
  */ | prdtrace==10 /* black-AI */ | prdtrace==11 /* black-asian */ /*
  */ | prdtrace==12 /* black-HP */ | prdtrace==15 /* W-B-AI */ | prdtrace==16 /*
  */ /* W-B-A */ | prdtrace==19) /* W-B-AI-A */
  replace wbho=4 if (1<=month & month<=4) & (3<=prdtrace & prdtrace<=5)
  replace wbho=4 if (1<=month & month<=4) & (prdtrace==7 /* white-AI */ /*
  */ | prdtrace==8 /* white-asian */ | prdtrace==9 /* white-hawaiian */ /*
  */ | prdtrace==13 /* AI-asian */ | prdtrace==14 /* Asian-HP */ /*
  */ | prdtrace==17 /* W-AI-A */ | prdtrace==18 /* W-A-HP */ | prdtrace==20 /*
  */ /* 2 or 3 races */ | prdtrace==21) /* 4 or 5 races */
  replace wbho=3 if (1<=month & month<=4) & (1<=prdthsp & prdthsp<=5) /* hisp */
	  
/* coding changed May 2012 */
  replace wbho=1 if (5<=month & month<=12) & prdtrace==1 /* white */
  replace wbho=2 if (5<=month & month<=12) & prdtrace==2 /* black */
  replace wbho=2 if (5<=month & month<=12) & (prdtrace==6 /* black-white */ /*
  */ | prdtrace==10 /* black-AI */ | prdtrace==11 /* black-asian */ /*
  */ | prdtrace==12 /* black-HP */ | prdtrace==16 /* W-B-AI */ | prdtrace==17 /*
  */ /* W-B-A */ | prdtrace==18 /* W-B-HP */ | prdtrace==22 /* B-AI-A */ /*
  */ | prdtrace==23) /* W-B-AI-A */
  replace wbho=4 if (5<=month & month<=12) & (3<=prdtrace & prdtrace<=5)
  replace wbho=4 if (5<=month & month<=12) & (prdtrace==7 /* white-AI */ /*
  */ | prdtrace==8 /* white-asian */ | prdtrace==9 /* white-hawaiian */ /*
  */ | prdtrace==13 /* AI-asian */ | prdtrace==14 /* AI-HP */ | prdtrace==15 /*
  */ /* Asian-HP */ | prdtrace==19 /* W-AI-A */ | prdtrace==20 /* W-AI-HP */ /*
  */ | prdtrace==21 /* W-A-HP */ | prdtrace==24 /* W-AI-A-HP */ | prdtrace==25 /*
  */ /* Other 3 races */ | prdtrace==26) /* 4 and 5 races */
  replace wbho=3 if (5<=month & month<=12) & (1<=prdthsp & prdthsp<=5) /* hisp */
	  
}
if 2013==`year' {
replace wbho=1 if prdtrace==1 /* white */
replace wbho=2 if prdtrace==2 /* black */
replace wbho=2 if prdtrace==6 /* black-white */ | prdtrace==10 /*
*/ /* black-AI */ | prdtrace==11 /* black-asian */ | prdtrace==12 /*
*/ /* black-HP */ | prdtrace==16 /* W-B-AI */ | prdtrace==17 /* W-B-A */ /*
*/ | prdtrace==18 /* W-B-HP */ | prdtrace==22 /* B-AI-A */ /*
*/ | prdtrace==23 /* W-B-AI-A */
replace wbho=4 if (3<=prdtrace & prdtrace<=5)
replace wbho=4 if prdtrace==7 /* white-AI */ | prdtrace==8 /*
*/ /* white-asian */ | prdtrace==9 /* white-hawaiian */ | prdtrace==13 /*
*/ /* AI-asian */ | prdtrace==14 /* AI-HP */ | prdtrace==15 /* Asian-HP */ /*
*/ | prdtrace==19 /* W-AI-A */ | prdtrace==20 /* W-AI-HP */ /*
*/ | prdtrace==21 /* W-A-HP */ | prdtrace==24 /* W-AI-A-HP */ /*
*/ | prdtrace==25 /* Other 3 races */ | prdtrace==26 /* 4 and 5 races */
replace wbho=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2014<=`year' & `year'<=2020 {
replace wbho=1 if prdtrace==1 /* white */
replace wbho=2 if prdtrace==2 /* black */
replace wbho=2 if prdtrace==6 /* black-white */ | prdtrace==10 /*
*/ /* black-AI */ | prdtrace==11 /* black-asian */ | prdtrace==12 /*
*/ /* black-HP */ | prdtrace==16 /* W-B-AI */ | prdtrace==17 /* W-B-A */ /*
*/ | prdtrace==18 /* W-B-HP */ | prdtrace==22 /* B-AI-A */ /*
*/ | prdtrace==23 /* W-B-AI-A */
replace wbho=4 if (3<=prdtrace & prdtrace<=5)
replace wbho=4 if prdtrace==7 /* white-AI */ | prdtrace==8 /*
*/ /* white-asian */ | prdtrace==9 /* white-hawaiian */ | prdtrace==13 /*
*/ /* AI-asian */ | prdtrace==14 /* AI-HP */ | prdtrace==15 /* Asian-HP */ /*
*/ | prdtrace==19 /* W-AI-A */ | prdtrace==20 /* W-AI-HP */ /*
*/ | prdtrace==21 /* W-A-HP */ | prdtrace==24 /* W-AI-A-HP */ /*
*/ | prdtrace==25 /* Other 3 races */ | prdtrace==26 /* 4 and 5 races */
replace wbho=3 if (1<=prdthsp & prdthsp<=8) /* hispanic */
}
lab var wbho "Race"
#delimit ;
lab define wbho
1 "White"
2 "Black"
3 "Hispanic"
4 "Other";
#delimit cr
lab val wbho wbho
notes wbho: Racial and ethnic categories are mutually exclusive
notes wbho: Major recoding of race variable in 2003
notes wbho: From 2003, black includes all respondents listing black; other /*
*/ includes all respondents listing non-white or non-black races, except /*
*/ those also listing black
notes wbho: CPS: derived from perace, prdtrace, ptdtrace, prorigin, prdthsp


	/* Race and ethnicity --separate category for Asian Pacific */

gen byte wbhao=.
if 1989<=`year' & `year'<=1991 {
replace wbhao=1 if adrace==1 /* white */
replace wbhao=2 if adrace==2 /* black */
replace wbhao=4 if adrace==4 /* asian */
replace wbhao=5 if adrace==3 | adrace==5 
/* american indian, aleut eskimo; asian or pacific island; other */
replace wbhao=3 if (1<=adreorgn & adreorgn<=7) /* hispanic */
}

if 1994<=`year' & `year'<=2002 {
replace wbhao=1 if perace==1 /* white */
replace wbhao=2 if perace==2 /* black */
replace wbhao=4 if perace==4 /* asian */
replace wbhao=5 if perace==3 | perace==5
/* american indian, aleut eskimo; asian or pacific island; other */
replace wbhao=3 if (1<=prorigin & prorigin<=7) /* hispanic */
} 
if 2003<=`year' & `year'<=2011 {
replace wbhao=1 if prdtrace==1 /* white only */
replace wbhao=2 if prdtrace==2 /* black only */
replace wbhao=2 if prdtrace==6 /* black-white */ | prdtrace==10 /*
*/ /* black-AI */ | prdtrace==11 /* black-asian */ | prdtrace==12 /*
*/ /* black-HP */ | prdtrace==15 /* W-B-AI */ | prdtrace==16 /* W-B-A */ /*
*/ | prdtrace==19 /* W-B-AI-A */
replace wbhao=4 if prdtrace==4 | prdtrace==5 /* asian & HP */ /*
*/ | prdtrace==8 /* white-asian */ | prdtrace==9 /* white-HP */ | prdtrace==13 /*
*/ /* AI-Asian */ | prdtrace==14 /* asian-HP */ | prdtrace==17 /* W-AI-A */ /*
*/ | prdtrace==18 /* W-A-HP */
replace wbhao=5 if prdtrace==3 /* AI only */ | prdtrace==7 /* white-AI */ /*
*/ | prdtrace==20 /* 2 or 3 races */ | prdtrace==21 /* 4 or 5 races */
replace wbhao=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2012==`year' {
  replace wbhao=1 if (1<=month & month<=4) & prdtrace==1 /* white only */
  replace wbhao=2 if (1<=month & month<=4) & prdtrace==2 /* black only */
  replace wbhao=2 if (1<=month & month<=4) & (prdtrace==6 /* black-white */ /*
  */ | prdtrace==10 /* black-AI */ | prdtrace==11 /* black-asian */ /*
  */ | prdtrace==12 /* black-HP */ | prdtrace==15 /* W-B-AI */ /*
  */ | prdtrace==16 /* W-B-A */ | prdtrace==19) /* W-B-AI-A */
  replace wbhao=4 if (1<=month & month<=4) & (prdtrace==4 | prdtrace==5 /*
  */ /* asian & HP */ | prdtrace==8 /* white-asian */ | prdtrace==9 /*
  */ /* white-HP */ | prdtrace==13 /* AI-Asian */ | prdtrace==14 /*
  */ /* asian-HP */ | prdtrace==17 /* W-AI-A */ | prdtrace==18) /* W-A-HP */
  replace wbhao=5 if (1<=month & month<=4) & (prdtrace==3 /* AI only */ /*
  */ | prdtrace==7 /* white-AI */ | prdtrace==20 /* 2 or 3 races */ /*
  */ | prdtrace==21) /* 4 or 5 races */
  replace wbhao=3 if (1<=month & month<=4) & (1<=prdthsp & prdthsp<=5) /* hisp */
  
/* coding changed May 2012 */
  replace wbhao=1 if (5<=month & month<=12) & prdtrace==1 /* white only */
  replace wbhao=2 if (5<=month & month<=12) & prdtrace==2 /* black only */
  replace wbhao=2 if (5<=month & month<=12) & (prdtrace==6 /* black-white */ /*
  */ | prdtrace==10 /* B-AI */ | prdtrace==11 /* B-A */ | prdtrace==12 /* B-HP */ /*
  */ | prdtrace==16 /* W-B-AI */ | prdtrace==17 /* W-B-A */ | prdtrace==18 /*
  */ /* W-B-HP */ | prdtrace==22 /* B-AI-A */ | prdtrace==23) /* W-B-AI-A */
  replace wbhao=4 if (5<=month & month<=12) & (prdtrace==4 | prdtrace==5 /*
  */ /* asian & HP */ | prdtrace==8 /* white-asian */ | prdtrace==9 /*
  */ /* white-HP */ | prdtrace==13 /* AI-Asian */ | prdtrace==14 /*AI-HP */ /*
  */ | prdtrace==15 /* asian-HP */ | prdtrace==19 /* W-AI-A */ /*
  */ | prdtrace==20 /* W-AI-HP */ | prdtrace==21 /* W-A-HP */ /*
  */ | prdtrace==24) /* W-AI-A-HP */
  replace wbhao=5 if (5<=month & month<=12) & (prdtrace==3 /* AI only */ /*
  */ | prdtrace==7 /* white-AI */ | prdtrace==25 /* Other 3 races */ /*
  */ | prdtrace==26 )/* Other 4 and 5 races */
  replace wbhao=3 if (5<=month & month<=12) & (1<=prdthsp & prdthsp<=5) /* hisp */
}	  
if 2013==`year' {
replace wbhao=1 if prdtrace==1 /* white only */
replace wbhao=2 if prdtrace==2 /* black only */
replace wbhao=2 if prdtrace==6 /* black-white */ | prdtrace==10 /*
*/ /* black-AI */ | prdtrace==11 /* black-asian */ | prdtrace==12 /*
*/ /* black-HP */ | prdtrace==16 /* W-B-AI */ | prdtrace==17 /* W-B-A */ /*
*/ | prdtrace==18 /* W-B-HP */ | prdtrace==22 /* B-AI-A */ /*
*/ | prdtrace==23 /* W-B-AI-A */
replace wbhao=4 if  prdtrace==4 | prdtrace==5 /* asian & hawaiian/pacific islander */ /*
*/ | prdtrace==8 /* white-asian */ | prdtrace==9 /* white-HP */ | prdtrace==13 /*
*/ /* AI-Asian */ | prdtrace==14 /*AI-HP */ | prdtrace==15 /* asian-HP */ /*
*/ | prdtrace==19 /* W-AI-A */ | prdtrace==20 /* W-AI-HP */ /*
*/ | prdtrace==21 /* W-A-HP */ | prdtrace==24 /* W-AI-A-HP */
replace wbhao=5 if prdtrace==3 /* AI only */ | prdtrace==7 /* white-AI */ /*
*/ | prdtrace==25 /* Other 3 races */ | prdtrace==26 /* Other 4 and 5 races */
replace wbhao=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2014<=`year' & `year'<=2020 {
replace wbhao=1 if prdtrace==1 /* white only */
replace wbhao=2 if prdtrace==2 /* black only */
replace wbhao=2 if prdtrace==6 /* black-white */ | prdtrace==10 /*
*/ /* black-AI */ | prdtrace==11 /* black-asian */ | prdtrace==12 /*
*/ /* black-HP */ | prdtrace==16 /* W-B-AI */ | prdtrace==17 /* W-B-A */ /*
*/ | prdtrace==18 /* W-B-HP */ | prdtrace==22 /* B-AI-A */ /*
*/ | prdtrace==23 /* W-B-AI-A */
replace wbhao=4 if  prdtrace==4 | prdtrace==5 /* asian & hawaiian/pacific islander */ /*
*/ | prdtrace==8 /* white-asian */ | prdtrace==9 /* white-HP */ | prdtrace==13 /*
*/ /* AI-Asian */ | prdtrace==14 /*AI-HP */ | prdtrace==15 /* asian-HP */ /*
*/ | prdtrace==19 /* W-AI-A */ | prdtrace==20 /* W-AI-HP */ /*
*/ | prdtrace==21 /* W-A-HP */ | prdtrace==24 /* W-AI-A-HP */
replace wbhao=5 if prdtrace==3 /* AI only */ | prdtrace==7 /* white-AI */ /*
*/ | prdtrace==25 /* Other 3 races */ | prdtrace==26 /* Other 4 and 5 races */
replace wbhao=3 if (1<=prdthsp & prdthsp<=8) /* hispanic */
}
lab var wbhao "Race/ethnicity, inc. Asian"
#delimit ;
lab define wbhao
1 "White"
2 "Black"
3 "Hispanic"
4 "Asian"
5 "Other"
;
#delimit cr
lab val wbhao wbhao
notes wbhao: Racial and ethnic categories are mutually exclusive
notes wbhao: From 2003, black includes all respondents listing black; asian /*
*/ includes all respondents listing asian (except those also listing black; /*
*/ other includes all respondents /*
*/ listing non-white, non-black or non-asian races, excluding those also /*
*/ listing black or asian
notes wbhao: asians include hawaiian/pacific islanders
notes wbhao: CPS: derived from prdthsp a-reorgn
notes wbhao: Available 89-on only

	/* wbhom */
	
gen byte wbhom=.

if 1979<=`year' & `year'<=2002 {
* wbhom not available
}
if 2003<=`year' & `year'<=2011 {
replace wbhom=1 if prdtrace==1
replace wbhom=2 if prdtrace==2
replace wbhom=4 if (3<=prdtrace & prdtrace<=5)
replace wbhom=5 if (6<=prdtrace & prdtrace<=21)
replace wbhom=4 if prdtrace==13 /* AI-asian */ | prdtrace==14 /* Asian-HP */ 
replace wbhom=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2012==`year' {
  replace wbhom=1 if (1<=month & month<=4) & prdtrace==1
  replace wbhom=2 if (1<=month & month<=4) & prdtrace==2
  replace wbhom=4 if (1<=month & month<=4) & (3<=prdtrace & prdtrace<=5)
  replace wbhom=5 if (1<=month & month<=4) & (6<=prdtrace & prdtrace<=21)
  replace wbhom=4 if (1<=month & month<=4) & (prdtrace==13 /* AI-asian */ /*
  */ | prdtrace==14) /* Asian-HP */
  replace wbhom=3 if (1<=month & month<=4) & (1<=prdthsp & prdthsp<=5) /* hisp */
	  
/* coding changed May 2012 */
  replace wbhom=1 if (5<=month & month<=12) & prdtrace==1
  replace wbhom=2 if (5<=month & month<=12) & prdtrace==2
  replace wbhom=4 if (5<=month & month<=12) & (3<=prdtrace & prdtrace<=5)
  replace wbhom=5 if (5<=month & month<=12) & (6<=prdtrace & prdtrace<=26)
  replace wbhom=4 if (5<=month & month<=12) & (prdtrace==13 /* AI-asian */ /*
  */ | prdtrace==14 /* AI-HP */ | prdtrace==15) /* Asian-HP */
  replace wbhom=3 if (5<=month & month<=12) & (1<=prdthsp & prdthsp<=5) /* hisp */	  
}
if 2013==`year' {
replace wbhom=1 if prdtrace==1
replace wbhom=2 if prdtrace==2
replace wbhom=4 if (3<=prdtrace & prdtrace<=5)
replace wbhom=5 if (6<=prdtrace & prdtrace<=26)
replace wbhom=4 if prdtrace==13 /* AI-asian */ | prdtrace==14 /* AI-HP */ /*
*/ | prdtrace==15 /* Asian-HP */
replace wbhom=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2014<=`year' & `year'<=2020 {
replace wbhom=1 if prdtrace==1
replace wbhom=2 if prdtrace==2
replace wbhom=4 if (3<=prdtrace & prdtrace<=5)
replace wbhom=5 if (6<=prdtrace & prdtrace<=26)
replace wbhom=4 if prdtrace==13 /* AI-asian */ | prdtrace==14 /* AI-HP 
*/ | prdtrace==15 /* Asian-HP */
replace wbhom=3 if (1<=prdthsp & prdthsp<=8) /* hispanic */
}
lab var wbhom "Race, inc. mixed"
#delimit ;
lab define wbhom
1 "White"
2 "Black"
3 "Hispanic"
4 "Other"
5 "Mixed";
#delimit cr
lab val wbhom wbhom

notes wbhom: Racial and ethnic categories are mutually exclusive
notes wbhom: CPS: derived from prdtrace
notes wbhom: Major recoding of race variable in 2003
notes wbhom: From 2003, black, white, and other exclude all respondents /*
*/ listing more than one race (except mixes of AI, Asian, and HP, which /*
*/ are included in other
notes wbhom: Not available 1979-2002
notes wbhom: CPS: derived from perace, prdtrace, and prorigin

	/* wbhaom */

gen byte wbhaom=.

if 2003<=`year' & `year'<=2011 {
replace wbhaom=1 if prdtrace==1
replace wbhaom=2 if prdtrace==2
replace wbhaom=4 if prdtrace==4 | prdtrace==5 /* Asian or HP */
replace wbhaom=5 if prdtrace==3 /* AI only */
replace wbhaom=6 if (6<=prdtrace & prdtrace<=21)
replace wbhaom=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2012==`year' {
  replace wbhaom=1 if (1<=month & month<=4) & prdtrace==1
  replace wbhaom=2 if (1<=month & month<=4) & prdtrace==2
  replace wbhaom=4 if (1<=month & month<=4) & (prdtrace==4 | prdtrace==5) /*
  */ /* Asian or HP */
  replace wbhaom=5 if (1<=month & month<=4) & prdtrace==3 /* AI only */
  replace wbhaom=6 if (1<=month & month<=4) & (6<=prdtrace & prdtrace<=21)
  replace wbhaom=3 if (1<=month & month<=4) & (1<=prdthsp & prdthsp<=5) /* hisp */

/* coding changed May 2012 */
  replace wbhaom=1 if (5<=month & month<=12) & prdtrace==1
  replace wbhaom=2 if (5<=month & month<=12) & prdtrace==2
  replace wbhaom=4 if (5<=month & month<=12) & (prdtrace==4 | prdtrace==5) /*
  */ /* Asian or HP */
  replace wbhaom=5 if (5<=month & month<=12) & prdtrace==3 /* AI only */
  replace wbhaom=6 if (5<=month & month<=12) & (6<=prdtrace & prdtrace<=26)
  replace wbhaom=3 if (5<=month & month<=12) & (1<=prdthsp & prdthsp<=5) /* hisp */  
}
if 2013==`year'{
replace wbhaom=1 if prdtrace==1
replace wbhaom=2 if prdtrace==2
replace wbhaom=4 if prdtrace==4 | prdtrace==5 /* Asian or HP */
replace wbhaom=5 if prdtrace==3 /* AI only */
replace wbhaom=6 if (6<=prdtrace & prdtrace<=26)
replace wbhaom=3 if (1<=prdthsp & prdthsp<=5) /* hispanic */
}
if 2014<=`year' & `year'<=2020 {
replace wbhaom=1 if prdtrace==1
replace wbhaom=2 if prdtrace==2
replace wbhaom=4 if prdtrace==4 | prdtrace==5 /* Asian or HP */
replace wbhaom=5 if prdtrace==3 /* AI only */
replace wbhaom=6 if (6<=prdtrace & prdtrace<=26)
replace wbhaom=3 if (1<=prdthsp & prdthsp<=8) /* hispanic */
}
lab var wbhaom "Race, inc. Asian and Mixed"
#delimit ;
lab define wbhaom
1 "White"
2 "Black"
3 "Hispanic"
4 "Asian"
5 "Native American"
6 "Mixed"
;
#delimit cr
lab val wbhaom wbhaom
notes wbhaom: Racial and ethnic categories are mutually exclusive
notes wbhaom: CPS: derived from prdthsp a-reorgn
notes wbhaom: Major recoding of race variable in 2003
notes wbhaom: From 2003, black, white, asian, and other exclude all /*
*/ respondents listing more than one race
notes wbhaom: Not available 1979-2002
notes wbhaom: CPS: derived from perace, prdtrace, and prorigin

	/* hawaiian/pacific islanders */

gen byte racehpia=.
gen byte racehpi=.

if 2003<=`year' & `year'<=2011 {
replace racehpia=0
replace racehpia=1 if prdtrace==5 /* hawaiian/pacific islander*/ /*
*/ | prdtrace==9 /* white-HP */ | prdtrace==14 /* asian-HP */ /*
*/ | prdtrace==18 /* W-A-HP */
}
if 2012==`year' {
  replace racehpia=0 if (1<=month & month<=4)
  replace racehpia=1 if (1<=month & month<=4) & (prdtrace==5 /* HP */ /*
  */ | prdtrace==9 /* white-HP */ | prdtrace==14 /* asian-HP */ /*
  */ | prdtrace==18) /* W-A-HP */

/* coding changed May 2012 */
  replace racehpia=0 if (5<=month & month<=12)
  replace racehpia=1 if (5<=month & month<=12) & (prdtrace==5 /* HP */ /*
  */ | prdtrace==9 /* white-HP */ | prdtrace==14 /* AI-HP */ /*
  */ | prdtrace==15 /* Asian-HP */ | prdtrace==20 /* W-AI-HP */ /*
  */ | prdtrace==21 /* W-A-HP */ | prdtrace==24) /* W-AI-A-HP */
}
if 2013<=`year' & `year'<=2020 {
replace racehpia=0
replace racehpia=1 if prdtrace==5 /* hawaiian/pacific islander*/ /*
*/ | prdtrace==9 /* white-HP */ | prdtrace==14 /* AI-HP */ /*
*/ | prdtrace==15 /* Asian-HP */ | prdtrace==20 /* W-AI-HP */ /*
*/ | prdtrace==21 /* W-A-HP */ | prdtrace==24 /* W-AI-A-HP */ 
}
lab var racehpia "Hawaiian/Pacific Islanders"
notes racehpia: CPS: derived from perace, prdtrace, prorigin
notes racehpia: Includes HPI, White-HP, Asian-HP, W-A-HP
notes racehpia: Available 2003-on

if 2003<=`year' & `year'<=2020 {
replace racehpi=1 if prdtrace==5
replace racehpi=0 if prdtrace~=5
}
lab var racehpi "Hawaiian/Pacific Islanders Only"
notes racehpi: CPS: derived from perace, prdtrace, prorigin
notes racehpi: Available 2003-on

/* Detailed Asian Origin Group */ 

if 1979<=`year' & `year'<=2012 {
gen byte racea=.
}

if 2013<=`year' & `year'<=2020 {
rename prdasian racea
}
lab var racea "Detailed Asian Origin"
#delimit ;
label define racea
1 "Asian Indian"                            
2 "Chinese"                                 
3 "Filipino"                                
4 "Japanese"                                
5 "Korean"                                  
6 "Vietnamese"                              
7 "Other"                                   
;
#delimit cr
lab val racea racea
notes racea: CPS: derived from prdasian
notes racea: Available 2013-on

/* Citizenship status and nativity (from 1994 only) */ 

gen byte forborn=.
gen byte citizen=.

if 1979<=`year' & `year'<=1993 {
gen byte prcitshp=.
}
if 1994<=`year' & `year'<=2020 {
replace forborn=0 if prcitshp~=.
replace forborn=1 if prcitshp==4 | prcitshp==5
*
replace citizen=0 if prcitshp~=.
replace citizen=1 if 1<=prcitshp & prcitshp<=4
}

lab var forborn "Foreign born"
notes forborn: Not available 1979-1993
notes forborn: CPS: derived from prcitshp

lab var citizen "US citizen"
notes citizen: Not available 1979-1993
notes citizen: CPS: derived from prcitshp

lab var prcitshp "Citizenship status"
capture lab drop prcitshp
#delimit ;
lab define prcitshp
1 "Born in US"
2 "Born in Puerto Rico, Outlying Areas"
3 "Foreign born, US parents"
4 "Foreign born, naturalized"
5 "Foreign born";
#delimit cr
lab val prcitshp prcitshp
notes prcitshp: Not available 1979-1993
notes prcitshp: CPS: prcitshp

/* Year arrived in the United States */

gen byte arrived=.

if 1994<=`year' & `year'<=2020 {
	if `year'==1994 {rename peinusyr prinusyr}
	if `year'==1995 { /* changes were made Sept 1995 */
	rename peinusyr old
	rename prinusyr new
	gen byte prinusyr=.
	replace prinusyr=old if (1<=month & month<=8)
	replace prinusyr=new if (9<=month & month<=12)
	}
	if `year'==2001 {capture rename prinuyer prinusyr}
	/* in 2005, for unknown reason, there are some observations that
	have a value for prinusyr, even though they were born in
	the U.S. For consistency, set to missing here */
	if `year'==2005 {replace prinusyr=. if prcitshp==1}
replace arrived=prinusyr 
replace arrived=. if prinusyr<=0
replace arrived=13 if 13<=prinusyr & prinusyr<=24
*
replace prinusyr=. if prinusyr<=0
}

lab var arrived "Year entered US"
capture lab drop arrived
#delimit ;
lab define arrived
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-";
#delimit cr
lab val arrived arrived
notes arrived: See "prinusyr" for year-specific variable
notes arrived: Not available 1979-1993
notes arrived: CPS: prinusyr

/*
due to inconsistencies over time in coding structure of prinusyr,
the last value of "arrived" (==13) refers to 1992 or later, with no
finer, consistent breakdown; in each individual year of the data, the 
dataset retains the inconsistently coded prinusyr variable for more 
detailed analysis
*/

if 1979<=`year' & `year'<=1993 {
gen byte prinusyr=.
}
if 1994<=`year' & `year'<=1995 {
capture lab drop usyr1994
#delimit ;
lab define usyr1994
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-95";
#delimit cr
lab val prinusyr usyr1994
}
if 1996<=`year' & `year'<=1997 {
capture lab drop usyr1996
#delimit ;
lab define usyr1996
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-97";
#delimit cr
lab val prinusyr usyr1996
}
if `year'==1998 {
#delimit ;
capture lab drop usyr1998
lab define usyr1998
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-98";
#delimit cr
lab val prinusyr usyr1998
}
if `year'==1999 {
capture lab drop usyr1999
#delimit ;
lab define usyr1999
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-99";
#delimit cr
lab val prinusyr usyr1999
}
if `year'==2000 {
capture lab drop usyr2000
#delimit ;
lab define usyr2000
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-00";
#delimit cr
lab val prinusyr usyr2000
}
/* according to NBER documentation, 16 in 2001 is "1998" only */
if `year'==2001 {
capture lab drop usyr2001
#delimit ;
lab define usyr2001
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-01";
#delimit cr
lab val prinusyr usyr2001
}
/* according to NBER documentation, 16 in 2001 is "1998" only */
if `year'==2002 {
capture lab drop usyr2002
#delimit ;
lab define usyr2002
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-02";
#delimit cr
lab val prinusyr usyr2002
}
*
if `year'==2003 {
capture lab drop usyr2003
#delimit ;
lab define usyr2003
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-03";
#delimit cr
lab val prinusyr usyr2003
}
if `year'==2004 {
capture lab drop usyr2004
#delimit ;
lab define usyr2004
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-04"
;
#delimit cr
lab val prinusyr usyr2004
}
if `year'==2005 {
capture lab drop usyr2005
#delimit ;
lab define usyr2005
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-05"
;
#delimit cr
lab val prinusyr usyr2005
}
if `year'==2006 {
capture lab drop usyr2006
#delimit ;
lab define usyr2006
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-06"
;
#delimit cr
lab val prinusyr usyr2006
}
if `year'==2007 {
capture lab drop usyr2007
#delimit ;
lab define usyr2007
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-07"
;
#delimit cr
lab val prinusyr usyr2007
}
if `year'==2008 {
capture lab drop usyr2008
#delimit ;
lab define usyr2008
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-08"
;
#delimit cr
lab val prinusyr usyr2008
}
if `year'==2009 {
capture lab drop usyr2009
#delimit ;
lab define usyr2009
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-09"
;
#delimit cr
lab val prinusyr usyr2009
}
if `year'==2010 {
capture lab drop usyr2010
#delimit ;
lab define usyr2010
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-07"
21 "2008-10"
;
#delimit cr
lab val prinusyr usyr2010
}
if `year'==2011 {
capture lab drop usyr2011
#delimit ;
lab define usyr2011
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-07"
21 "2008-2011"
;
#delimit cr
lab val prinusyr usyr2011
}
if `year'==2012 {
capture lab drop usyr2012
#delimit ;
lab define usyr2012
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-07"
21 "2008-09"
22 "2010-2012"
;
#delimit cr
lab val prinusyr usyr2012
}
if `year'==2013 {
capture lab drop usyr2013
#delimit ;
lab define usyr2013
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-07"
21 "2008-09"
22 "2010-2013"
;
#delimit cr
lab val prinusyr usyr2013
}
if `year'==2014 {
capture lab drop usyr2014
#delimit ;
lab define usyr2014
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-07"
21 "2008-09"
22 "2010-2011"
23 "2012-2014"
;
#delimit cr
lab val prinusyr usyr2014
}
if `year'==2015 {
capture lab drop usyr2015
#delimit ;
lab define usyr2015
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-07"
21 "2008-09"
22 "2010-2011"
23 "2012-2015"
;
#delimit cr
lab val prinusyr usyr2015
}
if `year'==2016 {
capture lab drop usyr2016
#delimit ;
lab define usyr2016
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-93"
14 "1994-95"
15 "1996-97"
16 "1998-99"
17 "2000-01"
18 "2002-03"
19 "2004-05"
20 "2006-07"
21 "2008-09"
22 "2010-2011"
23 "2012-2013"
24 "2014-2016"
;
#delimit cr
lab val prinusyr usyr2016
}
* FOR 2016 - this coding is preliminary

lab var prinusyr "Year entered US"
notes prinusyr: Coding not consistent across years
notes prinusyr: See "arrived" for variable that is consistent over time
notes prinusyr: Not available 1979-1993
notes prinusyr: CPS: prinusyr

/* Country of birth */

if 1979<=`year' & `year'<=1993 {
gen byte penatvty=. /* respondent */
gen byte pemntvty=. /* respondent's mother */
gen byte pefntvty=. /* respondent's father */
}
if 1994<=`year' & `year'<=2006 {
capture lab drop cob
#delimit ;
lab define cob
57  "United States"                 
60  "American Samoa"                
66  "Guam"                          
72  "Puerto Rico"                   
78  "U.S. Virgin Islands"           
96  "No coding available/US Outlying Area"
102 "Austria"                       
103 "Belgium"                       
105 "Czechoslovakia"                
106 "Denmark"                       
108 "Finland"                       
109 "France"                        
110 "Germany"                       
116 "Greece"                        
117 "Hungary"  
119 "Ireland/Eire"                  
120 "Italy"                         
126 "Holland/Netherlands"           
127 "Norway"                        
128 "Poland"                        
129 "Portugal"                      
130 "Azores"                        
132 "Romania"                       
134 "Spain"                         
136 "Sweden"                        
137 "Switzerland"                   
138 "Great Britain"                 
139 "England"                       
140 "Scotland"                      
142 "Northern Ireland"              
147 "Yugoslavia"                    
148 "Europe"                        
155 "Czech Republic"                
156 "Slovakia/Slovak Republic"      
180 "USSR"                          
183 "Latvia"                        
184 "Lithuania"                     
185 "Armenia"                       
192 "Russia"                        
195 "Ukraine"                       
200 "Afghanistan"                   
202 "Bangladesh"                    
205 "Burma"                         
206 "Cambodia"                      
207 "China"                         
209 "Hong Kong"                     
210 "India"                         
211 "Indonesia"                     
212 "Iran"                          
213 "Iraq"                          
214 "Israel"                        
215 "Japan"                         
216 "Jordan"                        
217 "Korea/South Korea"             
218 "Korea/ South Korea"            
221 "Laos"                          
222 "Lebanon"                       
224 "Malaysia"                      
229 "Pakistan"                      
231 "Philippines"                   
233 "Saudi Arabia"                  
234 "Singapore"                     
237 "Syria"                         
238 "Taiwan"                        
239 "Thailand"                      
240 "Turkey"                        
242 "Vietnam"                       
245 "Asia"                          
252 "Middle East"                   
253 "Palestine"                     
300 "Bermuda"                       
301 "Canada"                        
304 "North America"                 
310 "Belize"                        
311 "Costa Rica"                    
312 "El Salvador"                   
313 "Guatemala"                     
314 "Honduras"                      
315 "Mexico"                        
316 "Nicaragua"                     
317 "Panama"                        
318 "Central America"               
333 "Bahamas"                       
334 "Barbados"                      
337 "Cuba"                          
338 "Dominica"                      
339 "Dominican Republic"
340 "Grenada"            
342 "Haiti"                         
343 "Jamaica"                       
351 "Trinidad & Tobago"             
353 "Caribbean"                     
375 "Argentina"                     
376 "Bolivia"                       
377 "Brazil"                        
378 "Chile"                         
379 "Colombia"                      
380 "Ecuador"                       
383 "Guyana"                        
385 "Peru"                          
387 "Uruguay"                       
388 "Venezuela"                     
389 "South America"                 
415 "Egypt"                         
417 "Ethiopia"                      
421 "Ghana"                         
427 "Kenya"                         
436 "Morocco"                       
440 "Nigeria"                       
449 "South Africa"                  
462 "Other Africa"                  
468 "North Africa"                  
501 "Australia"                     
507 "Fiji"                          
514 "New Zealand"                   
527 "Pacific Islands"               
555 "Elsewhere"                         
;
#delimit cr
lab val penatvty cob
lab val pemntvty cob
lab val pefntvty cob
}
if 2007<=`year' & `year'<=2020 {
capture lab drop cob
#delimit ;
lab define cob
57  "United States"                 
60  "American Samoa"                
66  "Guam" 
69  "Northern Marianas"
73  "Puerto Rico"                   
78  "U.S. Virgin Islands"           
96  "Other US Island Areas"
100 "Albania"
102 "Austria"                       
103 "Belgium" 
104 "Bulgaria"                      
105 "Czechoslovakia"                
106 "Denmark"                       
108 "Finland"                       
109 "France"                        
110 "Germany"                       
116 "Greece"                        
117 "Hungary"                       
118 "Iceland"
119 "Ireland/Eire"                  
120 "Italy"                         
126 "Netherlands"           
127 "Norway"                        
128 "Poland"                        
129 "Portugal"                      
130 "Azores"                        
132 "Romania"                       
134 "Spain"                         
136 "Sweden"                        
137 "Switzerland"                   
138 "United Kingdom"                 
139 "England"                       
140 "Scotland" 
141 "Wales"                     
142 "Northern Ireland"              
147 "Yugoslavia"                    
148 "Czech Republic"                        
149 "Slovakia"                
150 "Bosnia & Herzegovina"
151 "Croatia"
152 "Macedonia"
154 "Serbia"
155 "Estonia"
156 "Latvia"
157 "Lithuania"                     
158 "Armenia"                       
159 "Azerbaijan"
160 "Belarus"
161 "Georgia"
162 "Moldova"
163 "Russia"                        
164 "Ukraine"       
165 "USSR"                                          
166 "Europe, n.s."
167 "Kosovo"
168 "Montenegro"
200 "Afghanistan"                   
202 "Bangladesh"
203 "Bhutan"                    
205 "Myanmar (Burma)"                         
206 "Cambodia"                      
207 "China"
208 "Cyprus"                         
209 "Hong Kong"                     
210 "India"                         
211 "Indonesia"                     
212 "Iran"                          
213 "Iraq"                          
214 "Israel"                        
215 "Japan"                         
216 "Jordan"                        
217 "Korea" 
218 "Kazakhstan"            
220 "South Korea"            
222 "Kuwait"
223 "Laos"
224 "Lebanon"                       
226 "Malaysia"  
228 "Mongolia"                    
229 "Nepal"
231 "Pakistan"                      
233 "Philippines"                   
235 "Saudi Arabia"                  
236 "Singapore"                     
238 "Sri Lanka"
239 "Syria"                         
240 "Taiwan"                        
242 "Thailand"                      
243 "Turkey"  
245 "United Arab Emirates"                      
246 "Uzbekistan"
247 "Vietnam"                       
248 "Yemen"
249 "Asia, n.s."                          
252 "Middle East"                   
300 "Bermuda"                       
301 "Canada"                        
303 "Mexico"                        
310 "Belize"                        
311 "Costa Rica"                    
312 "El Salvador"                   
313 "Guatemala"                     
314 "Honduras"                      
315 "Nicaragua"                     
316 "Panama"                        
321 "Antigua and Barbuda"
323 "Bahamas"                       
324 "Barbados"                      
327 "Cuba"                          
328 "Dominica"                      
329 "Dominican Republic"            
330 "Grenada"
332 "Haiti"                         
333 "Jamaica"                       
338 "St. Kitts--Nevis"
339 "St. Lucia"
340 "St. Vincent and the Grenadines"
341 "Trinidad & Tobago"             
343 "West Indies, n.s."                     
360 "Argentina"                     
361 "Bolivia"                       
362 "Brazil"                        
363 "Chile"                         
364 "Colombia"                      
365 "Ecuador"                       
368 "Guyana"                        
369 "Paraguay"
370 "Peru"                          
372 "Uruguay"                       
373 "Venezuela"                     
374 "South America, n.s."                 
399 "Americas, n.s."
400 "Algeria"
407 "Cameroon"
408 "Cape Verde"
412 "Congo"
414 "Egypt"                         
416 "Ethiopia"                      
417 "Eritrea"
421 "Ghana"
423 "Guinea"
425 "Ivory Coast"
427 "Kenya"                         
429 "Liberia"
430 "Libya"
436 "Morocco"                       
440 "Nigeria"                       
444 "Senegal"
447 "Sierra Leone"
448 "Somolia"
449 "South Africa"                  
451 "Sudan"
453 "Tanzania"
454 "Togo"
457 "Uganda"
459 "Zaire"
460 "Zambia"
461 "Zimbabwe"
462 "Africa, n.s."
501 "Australia"                     
508 "Fiji"  
511 "Marshall Islands"
512 "Micronesia"                        
515 "New Zealand"                   
523 "Tonga"
527 "Samoa"               
528 "Oceania, n.s."
555 "Elsewhere"                         
;
#delimit cr
lab val penatvty cob
lab val pemntvty cob
lab val pefntvty cob
}
lab var penatvty "Country birth"
notes penatvty: Not available 1979-1993
notes penatvty: CPS: penatvty

lab var pemntvty "Country birth, mother"
notes pemntvty: Not available 1979-1993
notes pemntvty: CPS: pemntvty

lab var pefntvty "Country birth, father"
notes pefntvty: Not available 1979-1993
notes pefntvty: CPS: pefntvty


/* Veteran */

gen byte vet=.

/*
if `year'<=1988 {
gen byte vet=0 if veteran~=.
replace vet=1 if 1<=veteran & veteran<=5
replace vet=. if female==1
}
*/
if `year'==1991 {
replace vet=0 if 1<=advet & advet<=6
replace vet=1 if 1<=advet & advet<=5
}
if 1994<=`year' & `year'<=2004 {
replace vet=0 if peafwhen~=.
replace vet=. if peafwhen==-1
replace vet=1 if 1<=peafwhen & peafwhen<=5 /* following NBER */
}
if 2005 ==`year' {
replace vet=0 if peafwhen~=. & (1<=month & month<=7)
replace vet=. if peafwhen==-1
replace vet=1 if 1<=peafwhen & peafwhen<=5 /* trying to follow NBER */

replace vet=0 if peafever==2 & (8<=month & month<=12)
replace vet=. if peafever==-1
replace vet=1 if 1<=peafwhn1 & peafwhn1<=9
}
if 2006<=`year' & `year'<=2020 {
replace vet=0 if peafever==2
replace vet=1 if 1<=peafwhn1 & peafwhn1<=9
}
lab var vet "Veteran"
notes vet: Question not asked consistently of women before 1989
notes vet: CPS: derived from peafever, peafwhen
notes vet: For 2005, made -1 = missing

/* 
Copyright 2020 CEPR and John Schmitt

This file is part of the cepr_org_master.do program. This file and all
programs referenced in it are free software. You can redistribute the
program or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA.
*/

